﻿<%@ WebHandler Language="C#" Class="Left" %>

using System;
using System.Web;
using WebApplication1.Base;

/// <summary>
/// Left 的摘要说明
/// </summary>
public class Left : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        context.Response.Write(table());
    }

    private string table()
    {
        string json = ""; string ls = "";
        //var table = new CommonLib.DbHelper.Table().DicTable;

        var list = DbSql.DB.Ado.SqlQuery<dynamic>("SELECT table_name as name, table_comment  as comment FROM information_schema.tables WHERE table_schema = 'base'");
        foreach (var item in list)
        {
            json += ls + "{";

            json += string.Format(@"""id"":""{0}"",", item.name);
            json += string.Format(@"""text"":""{0}"",", item.name);
            json += string.Format(@"""iconCls"":""{0}"",", "code-table");
            json += string.Format(@"""attributes"":{{""url"":""{0}"",""target"":""iframe""}},""state"":""open""", "Index.aspx?name=" + item.name);

            json += "}";
            ls = ",";
        }
        return "[" + json + "]";
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }
}